<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<h1>计算BMI</h1>
		<div id="">
			身高:<input type="text" id="input1"/><br>
			体重:<input type="text" id="input2"/><br>
			BMI:<span id="resultSpan"></span><br>
			<button onclick="cal()">计算BMI</button>
		</div>
		
		<script type="text/javascript">
			function cal()
			{
				
				var input1 = document.getElementById("input1");
				var height = input1.value;
				var input2 = document.getElementById("input2");
				var weight = input2.value;
				console.log(bmi = weight/height/height);
				var resultSpan = document.getElementById("resultSpan");
				resultSpan.innerHTML = bmi;
				
			}
			
		</script>
	</body>
</html>
